package action;

import dao.OrderDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/user/action/ReceiptConfirmServlet")
public class ReceiptConfirmServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String orderId = req.getParameter("orderId");
        OrderDao orderDao = new OrderDao();
        Integer row = orderDao.updateHandoverById(orderId);
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html");
        if (row>0){
            resp.getWriter().print("<script>alert('已确认收货！');window.location='../action/ShowOrderServlet?pageIndex=1&start=0&length=10'</script>");
        }
        else {

            resp.getWriter().print("<script>alert('确认收货失败！');window.location='../action/ShowOrderServlet?pageIndex=1&start=0&length=10'</script>");
        }
    }
}
